package com.CusterRelSys.control;

import com.CusterRelSys.entity.SalPlan;
import com.CusterRelSys.service.SalPlanService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/salPlan")
public class SalPlanControl {
    @Resource
    private SalPlanService salPlanService;
    @RequestMapping("/select")
    public String selectPlan(int chcId){
        List<SalPlan> salPlans = salPlanService.selectPlan(chcId);
        return null;
    }
    @RequestMapping("/updateSalPlan")
    public String updateSalPlan(SalPlan salPlan){
        int i = salPlanService.updateSalPlan(salPlan);
        if (i>0){
            return "redirect:/~sale/dev_plan.jsp";
        }else {
            return "~sale/dev_plan.jsp";
        }
    }
    @RequestMapping("/updataResult")
    public String updataResult(SalPlan salPlan){

        System.out.println("结果："+salPlan.toString());
        int i = salPlanService.updataResult(salPlan);
        if (i>0){
            return "redirect:/~sale/dev_plan.jsp";
        }else {
            return "~sale/dev_plan.jsp";
        }
    }
    @RequestMapping("/insetSalPlan")
    public String insertSalPlan(SalPlan salPlan){
        int i = salPlanService.insertSalPlan(salPlan);
        if (i>0){
            return "redirect:/~sale/dev_plan.jsp";
        }else {
            return "~sale/dev_plan.jsp";
        }
    }
    @RequestMapping("/deletSalPlan")
    public String deletSalPlan(int plaId){
        System.out.println("plaId"+plaId);
        int i = salPlanService.deletSalPlan(plaId);
        return "redirect:/~sale/dev_plan.jsp";
    }
}
